#ifndef DATACOLLECTOR_H
#define DATACOLLECTOR_H

#include <QObject>
#include <QThread>
#include "genagent.h"
#include "configdata.h"

class DataCollector : public QObject
{
    Q_OBJECT
public:
	static DataCollector *GetInstance();

private:
    DataCollector(QObject *parent = 0);
	QList<QThread *> m_threadList;
	QList<GenAgent *> m_agentList;
	static DataCollector *m_dataCollector;
	void addRstatAgent();

signals:
	// to agent
	void sendCommand(int genId, int type);
	void sendProfile(TProfile profile);
	void connectGen(int genId, TGenConfig config); // cannot use ref because of muti-thread
	void setServerIP(std::string ip);

	// to plotshow widget
	void connectCompleted(int genId, int status);
	void commandCompleted(int genId, int cmdType, int status);
	void tranDataArrived(int genId, QList<TTranData> incTranData);
	void userDataArrived(int genId, int incUser);
	void sumTranDataArrived(QList<TTranData> tranData);
	void sumUserDataArrived(int user);
	void rstatDataArrived(TRstatData rstatData);

public slots:
	void ConnectCompletedHandle(int genId, int status);
	void CommandCompletedHandle(int genId, int cmdType, int status);
	void TranDataArrivedHandle(int genId, QList<TTranData> incTranData);
	void UserDataArrivedHandle(int genId, int user);
	void RstatDataArrviedHandle(TRstatData rstatData);

	void AddAgent(int genId, const TGenConfig& config);
	void DelAgent(int genId);
	void StopAgent(int genId);
	void StartAgent();
	void SetServerIP(std::string ip);
};
#endif // DATACOLLECTOR_H
